var path = require("path");
var isDev = process.env.NODE_ENV === "development";

function resolve(dir) {
  return path.join(__dirname, dir);
}

let publicPath = "/";
let outputDir = "./dist";
let indexPath = "./index.html";

module.exports = {
  productionSourceMap: isDev,
  publicPath,
  outputDir,
  indexPath,
  lintOnSave: true,
  chainWebpack: (config) => {
    config.resolve.alias.set("@", resolve("src")); // 设置别名 @ 等于src

    // 全局scss变量
    const oneofsMap = config.module.rule("scss").oneOfs.store;
    oneofsMap.forEach((item) => {
      item
        .use("sass-resources-loader")
        .loader("sass-resources-loader")
        .options({
          resources: ["./src/styles/variables.scss"],
        });
    });
  },
  devServer: {
    proxy: {
      "/": {
        target: "http://192.168.18.119:8360/",
        ws: true,
        changeOrigin: true,
        pathRewrite: { "^/": "/" },
      },
    },
  },
};
